﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace IWMAG.Core.Objects {
    public abstract class DrawableGameObject : GameObject {
        protected Graphic Sprite;
        protected AnimationController Anim;
        public Vector2 Position = Vector2.Zero;
        protected SpriteEffects Effects = SpriteEffects.None;
        protected float Depth = 1;

        public virtual void Initialize(ContentManager content) {
        }

        public virtual void Draw(float elapsed, SpriteBatch batch) {
            if (Anim != null) {
                batch.Draw(Sprite.Sheet, Position, Sprite.GetFrame(Anim.GetFrame()), Color.White, 0f, Vector2.Zero, 1f, Effects, Depth);
            } else {
                batch.Draw(Sprite.Sheet, Position, Sprite.GetFrame(0), Color.White, 0f, Vector2.Zero, 10f, Effects, Depth);
            }
        }

        public override void Update(float elapsed) {
            if (Anim != null) {
                Anim.Update(elapsed);
            }
            base.Update(elapsed);
        }
    }
}
